<template>
  <GenericListPage :table-config="tableConfig" :header-actions="headerActions" />
</template>

<script>
import GenericListPage from '@/layout/components/GenericListPage'
import { getDaysAgo } from '@/utils/common'

export default {
  components: {
    GenericListPage
  },
  data() {
    const now = new Date()
    const dateFrom = getDaysAgo(7, now).toISOString()
    const dateTo = now.toISOString()
    return {
      tableConfig: {
        url: '/api/v1/audits/ftp-logs/',
        columns: [
          'user', 'asset', 'system_user', 'remote_addr', 'operate',
          'filename', 'is_success', 'date_start'
        ],
        columnsMeta: {
          user: {
            showOverflowTooltip: true
          },
          asset: {
            label: this.$t('assets.Assets'),
            showOverflowTooltip: true
          },
          system_user: {
            label: this.$t('assets.SystemUser'),
            showOverflowTooltip: true
          },
          remote_addr: {
            label: this.$t('sessions.remoteAddr'),
            width: '140px'
          },
          filename: {
            label: this.$t('perms.FileName'),
            showOverflowTooltip: true
          },
          operate: {
            label: this.$t('route.Operate'),
            width: '100px'
          },
          is_success: {
            label: this.$t('ops.isSuccess'),
            width: '80px'
          },
          date_start: {
            label: this.$t('sessions.dateStart')
          }
        },
        extraQuery: {
          date_to: dateTo,
          date_from: dateFrom
        }
      },
      headerActions: {
        hasLeftActions: false,
        hasImport: false,
        hasDatePicker: true,
        datePicker: {
          dateStart: dateFrom,
          dateEnd: dateTo
        }
      }
    }
  }
}
</script>

<style>

</style>
